<?php

/* EclipseBB:Includes:Classes::DB (db.class.php)
 *
 * This file creates the database class using the MySQL
 * protocol.
 *
 * (C) 2009 EclipseBB Group
*/

	class db 
	{
		public $conn = NULL;
		private $dbname;
		private $debug;
		
		function __construct() {
			/* Leaving for future use */
		}
		public function connect($u, $p, $h, $n) {
		{
			$this->conn = mysql_connect($h, $u, $p);
			if ($this->conn) 
			{
				if (@mysql_select_db($n)) 
				{
					return true;
				}
				else
				{
					if ($this->debug)
					{
						die(mysql_error());
					}
					else 
					{
						return false;
					}	
				}
			}
		
			else return false;
		}
		public function query($query)
		{
			if ($query != "")
			{
				mysql_query($query);
			}
		}
		public function checkLogin($user, $pass)
		{
			$result = $this->query("SELECT * FROM users WHERE user = '$user' AND  password = password('$pass')");
			if ($this->numrows($result) == 1) return true;
			else if ($this->debug)
			{
				die($this->numrows($result));
			else return false;
		}
		public function close()
		{
			mysql_close($conn);
		}
		public function numrows($result)
		{
			return mysql_num_rows($result);
		}		 
	}
?>